#!/bin/bash
#
 
#判断是否有密钥对
if [ -f /root/.ssh/id_rsa ]; then
  rm -rf /root/.ssh/id_rsa*
fi

#生成密钥对 
ssh-keygen -t rsa -f "/root/.ssh/id_rsa" -P "" &> /dev/null
 
> ~/.ssh/known_hosts

for i in 134 135; do
/usr/bin/expect << eof
set timeout 10
spawn ssh-copy-id root@192.168.80.$i
expect "(yes/no)?"
send "yes\n"
expect "password:"
send "redhat\n"
expect eof
eof
done
echo "----------------------------------------------------------"
for i in 134 135;do
  ssh root@192.168.80.$i hostname; date
done











